var e = getApp(), t = require("../../../mycomponent/yz_pay/yz_pay");

Page({
    behaviors: [ t ],
    data: {
        language: "",
        isclick: !0,
        order_id: "",
        orderData: null,
        balance: 0,
        payParams: "",
        info_form: {},
        order_sn: "",
        money: "",
        buttons: [],
        pay_sn: "订单编号",
        order_pay_id: "",
        uid: "",
        pid: "",
        status: ""
    },
    fromChild: function(e) {
        if ("0.00" == this.data.money) this.sureBtn(); else {
            var t = e.detail.submitArr;
            this.confirm(t);
        }
    },
    onLoad: function(e) {
        console.log(e.id), this.getPaycreate(e.id, e.supplier_id);
    },
    onReady: function() {
        var e = wx.getStorageSync("langIndex");
        this.setData({
            language: e.en
        });
    },
    confirm: function(e) {
        var t = e.value, a = e.submitArr;
        this.handlePay(a, t);
    },
    getPaycreate: function(t, a) {
        var r, o = this;
        r = t.toString().split(",");
        var s = e.getNetAddresss("plugin.supplier.frontend.insOrder.create"), d = {
            ids: r,
            supplier_id: a
        };
        e._postNetWork({
            url: s,
            data: d,
            success: function(e) {
                var t = e.data;
                console.log(t), 1 == t.result ? (console.log(t.data.order_ids), o.setData({
                    order_ids: t.data.order_ids
                }), o.getMultipleOrderInfo()) : wx.showToast({
                    icon: "none",
                    title: t.msg,
                    duration: 1500
                });
            },
            fail: function(e) {
                console.log(e);
            }
        });
    },
    getMultipleOrderInfo: function() {
        var t = this, a = this, r = e.getNetAddresss("order.merge-pay");
        "string" == typeof a.data.order_ids ? r += "&order_ids=" + a.data.order_ids : r += "&order_ids=" + JSON.parse(a.data.order_ids).toString(), 
        e._getNetWork({
            url: r,
            success: function(e) {
                var r = e.data.data;
                console.log("PayResult::::", r), 1 == e.data.result ? (t.hanleIcon(r), a.setData({
                    order_sn: r.order_pay.pay_sn,
                    balance: r.member.credit2,
                    money: r.order_pay.amount,
                    uid: r.order_pay.uid,
                    buttons: r.buttons
                }), a.data.order_pay_id = r.order_pay.id) : (wx.showToast({
                    title: e.data.msg,
                    icon: "success",
                    duration: 2e3
                }), console.log("错误", e.data.msg));
            }
        });
    }
});